//package com.angel.bo.auth.client.config.security.handler;
//
//import com.alibaba.fastjson.JSON;
//import com.angel.bo.common.msg.WebReturn;
//import org.springframework.core.annotation.Order;
//import org.springframework.http.HttpStatus;
//import org.springframework.security.access.AccessDeniedException;
//import org.springframework.security.web.access.AccessDeniedHandler;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
///**
// * @author zhangwei
// * @date 2018/4/28 9:37
// * @desc 自定义权限不足时的返回控制器,代替spring security默认的只抛异常并跳转页面的控制器(AccessDeniedHandlerImpl)
// */
//@Component
//@Order(Integer.MIN_VALUE)
//public class JsonAccessDenieHandler implements AccessDeniedHandler {
//
//    @Override
//    public void handle(HttpServletRequest httpServletRequest, HttpServletResponse response, AccessDeniedException e) throws IOException, ServletException {
//        WebReturn<Object> messageModel = new WebReturn<>(HttpStatus.UNAUTHORIZED);
//        response.setStatus(HttpStatus.FORBIDDEN.value());
//        response.setHeader("Content-Type", "application/json;charset=utf-8");
//        response.getWriter().print(JSON.toJSONString(messageModel));
//        response.getWriter().flush();
//    }
//}
